package com.dean.exception;

/**
 * DEAN SQL 异常信息
 * @author Administrator
 */
public class DeanRuntimeException extends RuntimeException{

    private static final long serialVersionUID = 520131420111119L;

    private Integer code;
    private String msg;

    public static DeanRuntimeException throwException(Integer code){
        throw  new DeanRuntimeException(code);
    }

    public static DeanRuntimeException throwException(String msg){
        throw new DeanRuntimeException(msg);

    }

    public static DeanRuntimeException throwException(Integer code, String msg){
        throw new DeanRuntimeException(code,msg);
    }

    public static DeanRuntimeException throwException(Integer code, String msg,Throwable throwable){
        throw new DeanRuntimeException(code,msg,throwable);
    }

    /**
     * 用于国际化 通过handler 提取具体的错误信息 只需要传入错误码
     * @param code
     */
    public DeanRuntimeException(Integer code) {
        super(code+"");
        this.code = code;
    }

    /**
     * 建议处理错误信息  提示对应的错误信息
     * @param msg
     */
    public DeanRuntimeException(String msg) {
        super(msg);
        this.msg = msg;
    }

    public DeanRuntimeException(Integer code, String msg) {
        super(msg);
        this.code = code;
        this.msg = msg;
    }

    public DeanRuntimeException(Integer code, String msg, Throwable cause) {
        super(msg,cause);
        this.code = code;
    }

    public Integer getCode(){
        return this.code;
    }

    public String getMsg(){
        return this.msg;
    }

}
